#ifndef AUDIOMANAGER_HEADER
#define AUDIOMANAGER_HEADER

#include <irrKlang.h>
#include <vector>

#include "..\Inputs\AbstractClasses\KeyboardListener.h"

class Sound;

//AudioManager should be created during GameEngine initialization
class AudioManager : public KeyboardListener {

public:
	static AudioManager * Instance();	//The public function to access the singleton
	static void create();				//creates the instance of AudioManager
	static void destroy();				//deletes the instance of AudioManager

	Sound* load(std::string);			//Load a sound to the AudioManager with the name of the file as it is in the folder ex. "pinkpanther.ogg"
	void unload(std::string);			//Unload a sound from the AudioManager with a name

	Sound* getSound(std::string) const;		//get the sound with the name

	void pauseAll();					//Pause all sounds playing
	void stopAll();						//Stop all sounds

	void setBackgroundSound(std::string);	//Sets the Background sound with the one of the loaded sounds
	void playBackgroundSound();				//Plays the setted background sound

	irrklang::ISoundEngine* getEngine() const;	//returns the irrKlang sound engine

	// Volume controls
	//Scale between 0 and 100;
    void setMasterVolume(int);				//Sets master volume
    void increaseMasterVolume();			//Increases master volume by 10
    void increaseMasterVolume(int);			//Increases master volume to the specified volume (0-100)
    void decreaseMasterVolume();			//Decreases master volume by 10
    void decreaseMasterVolume(int);			//Decreases master volume to the specified volume (0-100)
    int getCurrentMasterVolume() const;		//Returns master volume

	void onKeyPressed(int);					//Called when a key is presses on the keyboard
	void onKeyReleased(int);				//Called when a key is released on the keyboard

private:
	AudioManager();								//Constructor
	~AudioManager();							//Destructor
	static AudioManager * _instance;			//the one instance

	static irrklang::ISoundEngine* soundEngine;	//irrKlang sound engine
	static std::string filePath;				//File path to look for assets under it
	std::vector<Sound*> soundSourcesContainer;	//Container to keep loaded sounds
	Sound* backgroundSound;						//Background sound
	int _masterVolume;							//Master volume scale between 0 and 100
};

#endif